package com.ruoyi.web.controller.sj.controller;

import java.util.List;

import com.ruoyi.sj.domain.WqEweiShopMember;
import com.ruoyi.sj.service.IWqEweiShopMemberService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.sj.domain.BankCard;
import com.ruoyi.sj.service.IBankCardService;
import com.ruoyi.web.core.base.BaseController;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.common.base.AjaxResult;

/**
 * 银行卡绑定 信息操作处理
 *
 * @author tyc@yanyu.com
 * @date 2018-11-28
 */
@Controller
@RequestMapping("/sj/bankCard")
public class BankCardController extends BaseController {
    private String prefix = "sj/bankCard";

    @Autowired
    private IBankCardService bankCardService;
    @Autowired
    private IWqEweiShopMemberService wqEweiShopMemberService;

    @RequiresPermissions("sj:bankCard:view")
    @GetMapping()
    public String bankCard() {
        return prefix + "/bankCard";
    }

    /**
     * 查询银行卡绑定列表
     */
    @RequiresPermissions("sj:bankCard:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(BankCard bankCard) {
        startPage();
        List<BankCard> list = bankCardService.selectBankCardList(bankCard);
        return getDataTable(list);
    }

    /**
     * 新增银行卡绑定
     */
    @GetMapping("/add")
    public String add() {
        return prefix + "/add";
    }

    /**
     * 新增保存银行卡绑定
     */
    @RequiresPermissions("sj:bankCard:add")
    @Log(title = "银行卡绑定", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(BankCard bankCard) {
        return toAjax(bankCardService.insertBankCard(bankCard));
    }

    /**
     * 修改银行卡绑定
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap) {
        BankCard bankCard = bankCardService.selectBankCardById(id);
        mmap.put("bankCard", bankCard);
        return prefix + "/edit";
    }

    /**
     * 修改保存银行卡绑定
     */
    @RequiresPermissions("sj:bankCard:edit")
    @Log(title = "银行卡绑定", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(BankCard bankCard) {
        return toAjax(bankCardService.updateBankCard(bankCard));
    }

    /**
     * 删除银行卡绑定
     */
    @RequiresPermissions("sj:bankCard:remove")
    @Log(title = "银行卡绑定", businessType = BusinessType.DELETE)
    @PostMapping("/remove")
    @ResponseBody
    public AjaxResult remove(String ids) {
        return toAjax(bankCardService.deleteBankCardByIds(ids));
    }

   /* *//**
     * 通过用户id查询用户名
     * @param memberId
     * @param map
     * @return
     *//*
    @PostMapping("/edit/{memberId}")
    @ResponseBody
    public ModelMap queryById(@PathVariable Integer memberId,ModelMap map){
        WqEweiShopMember wqEweiShopMember = wqEweiShopMemberService.selectWqEweiShopMemberById(memberId);
        BankCard bankCard = new BankCard();
        bankCard.setUserName(wqEweiShopMember.getUsername());
        map.addAttribute("bankCard",bankCard);
        return map;
    }*/
}
